﻿
using OpenCvSharp;

using Xc.DataAccess.CodeReader.Properties;
using Xc.DataAccess.Core;

namespace Xc.DataAccess.CodeReader.Models.Filters
{
    /// <summary>
    /// 绘制带有箭头的线条
    /// </summary>
    [Filter("绘制带有箭头的线条",FilterType.Draw)]
    public class DrawArrowedLine : FilterBase
    {
        /// <summary>
        /// 粗细
        /// </summary>
        [InputParameter("位置1")]
        public CVPoint Point1 { get; set; }=new CVPoint();
        /// <summary>
        /// 粗细
        /// </summary>
        [InputParameter("位置2")] 
        public CVPoint Point2 { get; set; } = new CVPoint();
        /// <summary>
        /// 粗细
        /// </summary>
        [InputParameter("颜色")]
        public Scalar Color { get; set; }
        /// <summary>
        /// 粗细
        /// </summary>
        [InputParameter("粗细", ParameterType.Optional)]
        public int Thickness { get; set; } = 1;
        /// <summary>
        /// 线段类型
        /// </summary>
        [InputParameter("线段类型", ParameterType.Optional)]
        public LineTypes LineType { get; set; } = LineTypes.Link8;
        /// <summary>
        /// 偏移量
        /// </summary>
        [InputParameter("偏移量", ParameterType.Optional)]
        public int Shift { get; set; } = 0;
        /// <summary>
        /// 箭头长度
        /// </summary>
        [InputParameter("箭头长度", ParameterType.Optional)]
        public double TipLength { get; set; } = 0.1;

        internal override ResultData<Mat> UseChannel(Mat mat, FilterBase[] filterInfos, FilterBase preFilterBase)
        {
            Cv2.ArrowedLine(mat,Point1,Point2,Color,Thickness,LineType,Shift,TipLength);
            return ResultData<Mat>.Accept(TextResource.draw_success, mat);
        }
    }
}
